package itheima.edu.info.Exdents.Inface;

import java.math.BigDecimal;
import java.util.Arrays;

public class carTest {
    public static void main(String[] args) {
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int shoy = shoy(a, 9);
        System.out.println(shoy);
    }

    private static int shoy(int[] a, int i) {
        int min = 0;
        int max = a.length - 1;

        while (min <= max) {
            int mid = (min + max) / 2;
            if (a[mid] < i) {
                min = mid + 1;
            } else if (a[mid] > i) {
                max = mid - 1;
            } else {
                return mid;
            }
            }
        return  -1;
        }
}